package cn.stylefeng.guns.modular.rm;

import cn.hutool.core.date.DateTime;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.stylefeng.guns.constant.Constant;
import cn.stylefeng.guns.modular.rm.entity.RmGame;
import cn.stylefeng.guns.modular.rm.entity.RmGameScore;
import cn.stylefeng.guns.modular.rm.mapper.RmGameMapper;
import cn.stylefeng.guns.modular.rm.mapper.RmGameScoreMapper;
import cn.stylefeng.guns.modular.rm.service.RmGameScoreService;
import cn.stylefeng.guns.modular.rm.service.RmGameService;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

/**
 * @Description TODO
 * @Author xiesm
 * @Date 2024/4/17 15:03
 **/
@RestController
public class RMController {
    @Autowired
    private RmGameScoreService rmGameScoreServicer;
    @Autowired
    private RmGameService rmGameService;

    @RequestMapping("/cp/saveRmGame")
    public String saveGame() {
        String body = rmGameService.getGames(Constant.rmCookie[0], "0", null);
        rmGameService.getGame(body);
        return "ok";
    }

    @RequestMapping("/cp/saveRmGameScore")
    public String saveGameScore() {
        rmGameScoreServicer.getGameInfo(Constant.rmCookie[0]);
        return "ok";
    }


    @RequestMapping("/cp/saveRmCookie")
    public String saveRmCookie(String cookie) {
        cookie = cookie.replace(":", "%3A");
        Constant.rmCookie[0] = cookie;
        return "ok";
    }
    @RequestMapping("/cp/getRmCookie")
    public String getRmCookie() {
        return Constant.rmCookie[0];
    }









}
